package com.example.demo;

import com.example.demo.config.GirlConfig;
import com.example.demo.util.SocketUtils;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;

import java.util.Arrays;

@SpringBootApplication //启动springBOOT
@EnableConfigurationProperties({
		GirlConfig.class
})
public class DemoApplication {

	public static void main(String[] args) {

		SpringApplication.run(DemoApplication.class, args);
		//启动所有socketServer
		SocketUtils.isStartAll(1);

	}
	@Bean
	public ConfigurableServletWebServerFactory webServerFactory() {
		TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
		factory.addConnectorCustomizers((TomcatConnectorCustomizer) connector -> connector.setProperty("relaxedQueryChars", "|{}[]\\"));
		return factory;
	}

	//	@Bean
//	public CommandLineRunner commandLineRunner(ApplicationContext context){
//		return args -> {
//			System.out.println("检查spring-boot bean");
//			String[] bean = context.getBeanDefinitionNames();
//			Arrays.sort(bean);
//			for(String name:bean){
//				System.out.println(name);
//			}
//		};
//
//	}
}
